package org.dr.springmvcdemo.streamAPI;

/**
 * 并行流
 */

import java.util.Arrays;
import java.util.List;

/**
 * 并行处理
 */
public class ParallelStreamExample {
    public static void main(String[] args) {
        List<Integer> numbers = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);

        // 计算1到10的平方和
        int sum = numbers.parallelStream()
                .mapToInt(num -> num * num)
                .sum();

        System.out.println("Sum of squares: " + sum);
    }
}
